<?php
include 'sysco.function.php';

$con = mysql_connect($HOST, $USER, $PASS);
mysql_select_db($DB);

//$menuProdCountArr = array('lp000051383792' => 506, 'lp000051396857' => 292, 'lpLaVigaRwc' => 121);
//$menuProdCount = $menuProdCountArr[$MERCHANT];

$MERCHANTArr = array('lp000051403449' => 'Vino Santo', 'lpLaVigaRwc' => 'La Viga', 'lpMagdaBg' => 'Magda Luna', 'lpAthertonSubsRwc' => 'Atherton Subs', 'lp000051383792' => 'Pronto pitza');
$menuProdCount = getProductCount($MERCHANT);

if ($month == 1) {
  $_SESSION['from'] = '2012-12-02 03:00:00';
  $_SESSION['to'] = '2013-02-01 02:59:00';
} else if ($month == 2) {
  $_SESSION['from'] = '2012-12-30 03:00:00';
  $_SESSION['to'] = '2013-03-01 02:59:00';
} else if ($month == 3) {
  $_SESSION['from'] = '2013-01-31 03:00:00';
  $_SESSION['to'] = '2013-04-01 02:59:00';
}

$noOrdersItems = getNoSoldItems($MERCHANT);
$noOrdersItems = count($noOrdersItems); 

$prc = $noOrdersItems / $menuProdCount;
echo "---------------------\n";
echo $noOrdersItems.' Items (='.round($prc*100).'%) did not sell in the last 60 days'."\n";

// for reporting period
if ($month == 1) {
  $_SESSION['from'] = '2013-01-01 03:00:00';
  $_SESSION['to'] = '2013-02-01 02:59:00';
} else if ($month == 2) {
  $_SESSION['from'] = '2013-02-01 03:00:00';
  $_SESSION['to'] = '2013-03-01 02:59:00';
} else if ($month == 3) {
  $_SESSION['from'] = '2013-03-01 03:00:00';
  $_SESSION['to'] = '2013-04-01 02:59:00';
}

$noOrdersItems = getNoSoldItems($MERCHANT);
$noOrdersItems = count($noOrdersItems);

$prc = $noOrdersItems / $menuProdCount;
echo $noOrdersItems.' Items (='.round($prc*100).'%) did not sell during the selected period'."\n";
echo $MERCHANTArr[$MERCHANT]." - ".date('F', strtotime($_SESSION['from']))."\n";
echo "------------- \n";



// echo getTotalUnits($MERCHANT). " item sale for period \n";
?>
